package com.study.talk.app.home.fragment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ListView;

import androidx.annotation.NonNull;
import androidx.appcompat.widget.SearchView;

import com.study.talk.R;
import com.study.talk.app.base.BaseFragment;
import com.study.talk.app.moment.MomentListActivity;
import com.study.talk.databinding.FragmentOtherBinding;

import java.util.ArrayList;

public class OtherFragment extends BaseFragment {

    private Activity activity;
    private FragmentOtherBinding fragmentOtherBinding;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        activity = getActivity();
    }

    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        fragmentOtherBinding = FragmentOtherBinding.inflate(inflater, container, false);
        initData();
        return fragmentOtherBinding.getRoot();
    }

    private void initData() {
        ArrayList<String> menu = new ArrayList<>();

        menu.add("动态");

        fragmentOtherBinding.otherFragmentListView.setAdapter(new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1, menu));

        fragmentOtherBinding.otherFragmentListView.setOnItemClickListener((parent, view1, position, id) -> {
            if (position == 0) {
                Intent intent = new Intent(activity, MomentListActivity.class);
                intent.putExtra(MomentListActivity.typeName, MomentListActivity.MOMENT_ALL); //默认是本地用户查看其所有朋友的朋友圈
                startActivity(intent);
            }
        });

    }
}